import SHA256 from "../../utils/sha256.js"
import { request } from "../../utils/request.js"

const login = (username, password) => {
    
    return request({
        url: '/user/login',
        method: 'post',
        data: {
            username,
            password: SHA256(password)
        }
    })

}
const loginEmail = (email, code) => {
    return request({
        url: '/user/elogin',
        method: 'post',
        data: {
            email,
            code
        }
    })
}

const registry = (username, password, email) => {
    return request({
        url: '/user/registry',
        method: 'post',
        data: {
            username,
            password: SHA256(password),
            email
        }
    })
}

const logout = () => {
    window.location.reload()
}


export {
    login, loginEmail, logout, registry
}